import cv2
import numpy as np
import matplotlib.pyplot as plt
img=cv2.imread('44.PNG')
enable=False
def call_back_draw(event,x,y,flags,param):
    global enable
    if event==cv2.EVENT_LBUTTONDOWN:
        enable=True
    elif event==cv2.EVENT_MBUTTONDBLCLK and flags==cv2.EVENT_FLAG_LBUTTON:
        if enable:
            drawMask(x,y)
    elif event==cv2.EVENT_LBUTTONUP:
        enable=False
def drawMask(x,y,size=10):
    m=np.uint8(x/size)*size
    n=np.uint8(y/size)*size
    for i in range(size):
        for j in range(size):
            img[m+i,n+j]=img[m,n]
cv2.namedWindow('image')
cv2.setMouseCallback('image',call_back_draw)
titles=['src','sampling']
images=['src','new_img']
plt.figure(figsize=(10,4))
for i in range(2):
    plt.subplot(1,2,i+1)
    plt.imshow(images[i])
    plt.title(titles[i])
    plt.axis('off')
plt.show()